
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html.
# For more examples on how to use CMake, see https://github.com/android/ndk-samples.

# Sets the minimum CMake version required for this project.
cmake_minimum_required(VERSION 3.22.1)

include_directories(include)
include_directories(include/libyuv)

message("路径:${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI} 工程名称：${CMAKE_PROJECT_NAME}")

#设置动态依赖库,相当于将路径配置到环境变量,后续target_link_libraries可直接使用
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI}")


aux_source_directory(. SOURCE)
# Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
# Since this is the top level CMakeLists.txt, the project name is also accessible
# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
# build script scope).
project("vediotest")

add_library(${CMAKE_PROJECT_NAME} SHARED
        # List C/C++ source files with relative paths to this CMakeLists.txt.
        ${SOURCE})

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
#
# In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define
# the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME}
# is preferred for the same purpose.
#
# In order to load a library into your app from Java/Kotlin, you must call
# System.loadLibrary() and pass the name of the library defined here;
# for GameActivity/NativeActivity derived applications, the same library name must be
# used in the AndroidManifest.xml file.
#add_library(avcodec SHARED IMPORTED)
#add_library(yuv SHARED IMPORTED)
#add_library(avformat SHARED IMPORTED)
#add_library(avfilter SHARED IMPORTED)
#add_library(avutil SHARED IMPORTED)
#add_library(postproc SHARED IMPORTED)
#add_library(swresample SHARED IMPORTED)
#add_library(swscale SHARED IMPORTED)
#
#set_target_properties(avcodec PROPERTIES
#        IMPORTED_LOCATION
#        ${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI}/libavcodec.so)
#set_target_properties(yuv PROPERTIES
#        IMPORTED_LOCATION
#        ${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI}/libyuv.so)
#set_target_properties(avformat PROPERTIES
#        IMPORTED_LOCATION
#        ${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI}/libavformat.so)
#set_target_properties(avutil PROPERTIES
#        IMPORTED_LOCATION
#        ${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI}/libavutil.so)
#set_target_properties(avfilter PROPERTIES
#        IMPORTED_LOCATION
#        ${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI}/libavfilter.so)
#set_target_properties(postproc PROPERTIES
#        IMPORTED_LOCATION
#        ${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI}/libpostproc.so)
#set_target_properties(swresample PROPERTIES
#        IMPORTED_LOCATION
#        ${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI}/libswresample.so)
#set_target_properties(swscale PROPERTIES
#        IMPORTED_LOCATION
#        ${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI}/libswscale.so)

add_library(ffmpeg SHARED IMPORTED)
add_library(yuv SHARED IMPORTED)
set_target_properties(ffmpeg PROPERTIES
        IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/simpleLibs/${ANDROID_ABI}/libffmpeg.so)

set_target_properties(yuv PROPERTIES
        IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/ffmpeglibs/${ANDROID_ABI}/libyuv.so)

# Specifies libraries CMake should link to your target library. You
# can link libraries from various origins, such as libraries defined in this
# build script, prebuilt third-party libraries, or Android system libraries.
#target_link_libraries(${CMAKE_PROJECT_NAME}
#        # List libraries link to the target library
#        android
#        log
#        avcodec
#        avformat
#        avutil
#        avfilter
#        postproc
#        swresample
#        swscale
#        yuv)

target_link_libraries(${CMAKE_PROJECT_NAME}
        # List libraries link to the target library
        android
        log
        ffmpeg
        yuv)
